# lowest priced itinerary with maximum layover allowed (over all stops) upto k hours

# max-allowed layover at any intermediate node
# note: for forced via points, if a minimum layover is specified,
# we enforce a modified version of this constraint.
# Please see forced_stop.mod
subject to max_layover {i in nodes diff {source, dest} diff p_forced_via_point}:
sum {(i,j,k,l) in ARCS} itinerary[i,j,k,l]*(24*(l-1) + floor(depart_tm[k]/100) + (depart_tm[k] mod 100)/60)
- sum {(o,i,m,n) in ARCS} itinerary[o,i,m,n]*(24*(n + arrive_day[m] - 1) + floor(arrive_tm[m]/100) + (arrive_tm[m] mod 100)/60) <= max_allowed_layover;

# max-allowed total layover at all intermediate nodes
# this includes layover at all intermediate nodes
subject to c_max_totl_layover:
sum {i in nodes diff {source, dest}}
(sum {(i,j,k,l) in ARCS} itinerary[i,j,k,l]*(24*(l-1) + floor(depart_tm[k]/100) + (depart_tm[k] mod 100)/60)
- sum {(o,i,m,n) in ARCS} itinerary[o,i,m,n]*(24*(n + arrive_day[m] -1) + floor(arrive_tm[m]/100) + (arrive_tm[m] mod 100)/60)) <= p_max_totl_layover;


